//
//  YSL_FlyweightTicket.swift
//  ArchitectGenerics
//
//  Created by 姚胜龙 on 2017/6/19.
//  Copyright © 2017年 姚胜龙. All rights reserved.
//

import UIKit

//具体的享元对象 实现类(火车)
class YSL_FlyweightTicket: YSL_FlyweightProtocol {
    private var from:String
    private var to:String
    private var bunk:String?
    private var price:Int = 0

    init(from:String,to:String) {
        self.from = from
        self.to = to
    }
    func showTicketInfo(bunk: String) {
        self.bunk = bunk;
        if bunk == "硬座" {
            self.price = 81
        }
        else if (bunk == "硬卧") {
            self.price = 144
        }
        else if (bunk == "软座") {
            self.price = 256
        }
        else if (bunk == "软卧") {
            self.price = 444
        }
        else if (bunk == "二等座") {
            self.price = 400
        }
        else if (bunk == "一等座") {
            self.price = 856
        }
        else if (bunk == "商务座") {
            self.price = 1440
        }
        print("起点：\(self.from) 终点：\(self.to) 价格：\(self.price) 座次：\(self.bunk!)")
    }
}
